<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="java.net.URLEncoder"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>自己省 书签页</title>
		<meta http-equiv="keywords" content="淘宝 返利 省钱 自己省 书签" />
		<meta http-equiv="description" content="淘宝省钱书签" />
		<meta http-equiv="imagetoolbar" content="no" />
		<meta name="MSSmartTagsPreventParsing" content="true" />
		<meta name="robots" content="nofollow" />
		<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
		<meta http-equiv="pragma" content="no-cache" />
		<meta http-equiv="Cache-Control" content="no-cache,no-store,must-revalidate" />
		<meta http-equiv="expires" content="-1" />
		<link rel="shortcut icon" type="image/vnd.microsoft.icon" href="favicon.ico" />
		<link rel="icon" type="image/vnd.microsoft.icon" href="favicon.ico" /> 
		<link rel="stylesheet" type="text/css" href="css/bmpublic.css" />
		<script type="text/javascript" src="js/mootools-1.2.2-core-yc.js"></script>
	</head>
	<body>
		<%
			String i=request.getParameter("i");
			String n=request.getParameter("n");
			if(i==null||n==null){
				response.sendRedirect("error.jsp");
			}
			n = new String(n.getBytes("ISO-8859-1"),"UTF-8");
			i=URLEncoder.encode(i,"UTF-8");
			n=URLEncoder.encode(n,"UTF-8");
		%>
		<div class="main">
			<div id="loading" style="display:block;"><img class="loading" id="changeLoading" src="img/loading.gif" />loading..</div>
			<div id="res" style="display:none;">
				<table class="mainTbl">
					<tr>
						<td><div class="tag">原价</div><div class="info" id="_price" style="text-decoration:line-through;"></div></td>
						<td><div class="tag">折后价</div><div class="info" id="_priceNow" style="color:red;"></div></td>
						<td style="width:100px;background-color:#ccc;" rowspan="2"><div style="width:100px;height:50px;line-height:50px;text-align:center;vertical-align:middle;cursor:pointer;" id="_clickUrl">GO!</div></td>
					</tr>
					<tr>
						<td><div class="tag">折扣(节省)</div><div class="info" id="_commissionRate" style="color:green;"></div></td>
						<td><div class="tag">30天交易量</div><div class="info" id="_volume"></div></td>
					</tr>
				</table>
			</div>
			<div id="err" style="display:none;"></div>
		</div>
		<script type="text/javascript">
			var u='http://localhost:8888/convert?i=<%=i%>&n=<%=n%>&r='+Math.random();
			new Request.JSON({
	            url: u,
	            method:'get' ,
	            onComplete: function(res) {
	                var err=res.err;
	                $('loading').style.display='none';
	                if(err){
	                	$('err').set('text',err);
	                	$('err').style.display='block';
		            }else{
			            var _p=res.ori_price;
			            var _pp=res.promo_price;
		            	//var _c=res.commission;
		            	var _cr=res.commission_rate/100;
		            	$('_price').set('text','￥'+_p+'('+_pp+')');
		            	$('_volume').set('text',res.volume+'笔');
		            	$('_priceNow').set('text','￥'+(parseFloat(_pp)*(1-res.commission_rate/10000)).toFixed(2));
		            	$('_commissionRate').set('text','-'+_cr+'%(￥'+(parseFloat(_pp)*res.commission_rate/10000)+')');
		            	$('res').style.display='block';
		            	//$('_clickUrl').href=res.click_url;
		            	$('_clickUrl').addEvent('click', function(){window.parent.location.href=res.click_url;});
			        }
	            }
	        }).send();
		</script>
	</body>
</html>
